import { handleAction, handleActions } from 'redux-actions'
import { actionTypes } from '../../action/counter'

const initialState = 10
export default (state = initialState, { type, payload = 1 }) => {
    switch (type) {
        case actionTypes.increase:
            return state + payload
        case actionTypes.decrease:
            return state - payload
        default:
            return state
    }
}

// const reducer = handleAction("increase", (state, actions) => state + 1, initialState)

const reducer = handleActions({
    increase: state => state + 1,
    decrease: state => state - 1,
}, 0) // 默认值